package com.zygh.lz.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zygh.lz.entity.Gps;
import com.zygh.lz.entity.remould.Patrol;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.security.core.parameters.P;

import java.lang.reflect.MalformedParameterizedTypeException;
import java.rmi.MarshalledObject;
import java.util.List;
import java.util.Map;

@Mapper
public interface GpsMapper extends BaseMapper<Gps> {
    int deleteByPrimaryKey(Integer sysGpsId);

    int deleteByPatrolId(Integer id);

    int insert(Gps record);

    int insertSelective(Gps record);

    Gps selectByPrimaryKey(Integer sysGpsId);

    int updateByPrimaryKeySelective(Gps record);

    int updateByPrimaryKey(Gps record);

    List<Gps> selectGpsByRecord(@Param("staffId") int sys_staff_id,
                                @Param("sysPatrolRecordId") int sysPatrolRecordId);

    List<Map> selectGpsByRecordes(int sysPatrolRecordId);


    //根据时间查询轨迹标识
    List<Map> findGpsSignNum(@Param("startTime") String startTime,
                             @Param("endTime") String endTime,
                             @Param("sectionPid") Integer sectionPid,
                             @Param("staffId") Integer staffId);

    //根据签到标识查询坐标
    List<Gps> findGpsBySignNum(String signnum);

    List<Gps> testGps(String signnum);

    double selectmileageByGps(int sysPatrolRecordId);


    List<Gps> selectAllGps();

    //最新GPS定位点
    Gps gpsEnd(Integer id);

    List<Gps> selectGpsByRecords(@Param("sys_staff_id") int sys_staff_id,
                                 @Param("sysPatrolRecordId") int sysPatrolRecordId);


    //根据警员id查询警员最新的一个坐标点
    Map RealTimeGPS(Integer id);

    //根据id和时间查询该警员巡查总里程
    double findMileage(@Param("staffId") Integer staffId,
                       @Param("startDate") String startDate,
                       @Param("endDate") String endDate);


    //根据签到id
    double findMileages(String signNum);


    //根据时间、大队查询巡查总里程
    double totalDistance(@Param("sectionId") Integer sectionId,
                         @Param("startTime") String startTime,
                         @Param("endTime") String endTime);


    //当天巡查里程排名
    List<Map<String, Object>> totalDistanceByTime(@Param("sectionId") Integer sectionId,
                                                  @Param("startTime") String startTime,
                                                  @Param("endTime") String endTime);


    //根据时间、中队查询巡查总里程
    double totalDistanceLochus(@Param("sectionId") Integer sectionId,
                               @Param("startTime") String startTime,
                               @Param("endTime") String endTime);

    double totalDistanceByLochus(@Param("sectionId") Integer sectionId,
                                 @Param("startTime") String startTime,
                                 @Param("endTime") String endTime);


    List<Map<String, Object>> totalLochusByTime(@Param("sectionId") Integer sectionId,
                                                @Param("startTime") String startTime,
                                                @Param("endTime") String endTime);


    //根据时间、人员查询巡查总里程
    double distanceByStaffId(@Param("staffId") Integer staffId,
                             @Param("startTime") String startTime,
                             @Param("endTime") String endTime);


    //根据时间、人员查询巡查总里程前三十名
    List<Map<String, Object>> distanceBySectionId(@Param("sectionId") Integer sectionId,
                                                  @Param("startTime") String startTime,
                                                  @Param("endTime") String endTime);


    //出勤街道统计
    List<Map> gateStreet(@Param("staffId") Integer staffId,
                         @Param("startTime") String startTime,
                         @Param("endTime") String endTime);


    //获取活跃度
    int findactivity(@Param("sectionId") Integer sectionId,
                     @Param("startTime") String startTime,
                     @Param("endTime") String endTime);

}